//
//  WACommentDetailController.m
//  WalkiOS
//
//  Created by luqiuan on 2019/11/6.
//  Copyright © 2019 Chenmuzhou. All rights reserved.
//

#import "WACommentDetailController.h"

@interface WACommentDetailController ()

@property (weak, nonatomic) IBOutlet UITextView *textView;
@end

@implementation WACommentDetailController

- (instancetype)initWithModel:(WACommentModel *)model
{
    self = [super init];
    if (self) {
        self.model = model;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.textView.editable = NO;
    self.textView.attributedText = [self commentWithString:self.model.content];
}

- (IBAction)backAction:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}


//评论排版
- (NSAttributedString *)commentWithString:(NSString *)string{
    if (!string) {
        string = @"";
    }
    NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithString:string];
    //字体大小
    [attributeString addAttribute:NSFontAttributeName
                            value:[UIFont systemFontOfSize:17.5]
                            range:NSMakeRange(0, string.length)];
    //字体颜色
    [attributeString addAttribute:NSForegroundColorAttributeName
                            value:WNHexColor(0xffffff)
                            range:NSMakeRange(0, string.length)];
    
    //段落
    NSMutableParagraphStyle   *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    paragraphStyle.lineSpacing = 5;
    [attributeString addAttribute:NSParagraphStyleAttributeName
                            value:paragraphStyle
                            range:NSMakeRange(0, string.length)];//设置段落样式
    return [attributeString copy];
}
@end
